# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libdvdread
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=6.1.1
pkgrel=1
pkgdesc="Provides a simple foundation for reading DVD video disks (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://dvdnav.mplayerhq.hu"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-doxygen"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "git")
depends=("${MINGW_PACKAGE_PREFIX}-libdvdcss")
options=('staticlibs' 'strip')
source=("https://download.videolan.org/pub/videolan/${_realname}/${pkgver}/${_realname}-${pkgver}.tar.bz2"{,.asc}
        #"${_realname}-${pkgver}"::"git+https://code.videolan.org/videolan/${_realname}.git#tag=${pkgver}"
        0001-no-undefined-on.all.patch)
sha256sums=('3e357309a17c5be3731385b9eabda6b7e3fa010f46022a06f104553bf8e21796'
            'SKIP'
            'd8930c4167b9f9524b164f3ab918c3e8289acca3d86cd92146fd79453a5e9b58')
validpgpkeys=('65F7C6B4206BD057A7EB73787180713BE58D1ADC') # VideoLAN Release Signing Key

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-no-undefined-on.all.patch
  autoreconf -fi
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --disable-dlfcn \
    --with-libdvdcss
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
